package 多线程;

/**
 * @description: 生产者
 * @author: rock
 * @create:
 **/
public class Producer extends Thread {
    private Stack stack;

    public Producer(Stack stack) {
        this.stack = stack;
    }

    @Override
    public void run() {
        //业务逻辑处理
        for (int i=0;i<=2;i++){
            Goods goods = new Goods("nihao",10.5);
//            System.out.println("生产了"+goods.getGoodsName()+","+goods.getGoodsPrise()+"元");
            stack.push(goods);

            //线程休眠1000ms
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
